package com.jiangyg.mall.member.service;

import com.jiangyg.mall.core.support.restful.Pagination;
import com.jiangyg.mall.db.mybatis.BaseServiceImpl;
import com.jiangyg.mall.member.dao.GrowthChangeHistoryDao;
import com.jiangyg.mall.member.dto.GrowthChangeHistoryDTO;
import com.jiangyg.mall.member.entity.GrowthChangeHistory;
import com.jiangyg.mall.member.vo.GrowthChangeHistoryVO;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class GrowthChangeHistoryServiceImpl extends BaseServiceImpl<GrowthChangeHistoryDao, GrowthChangeHistory> implements GrowthChangeHistoryService {

    @Autowired
    public GrowthChangeHistoryServiceImpl(GrowthChangeHistoryDao growthChangeHistoryDao) {
        super(growthChangeHistoryDao);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public Pagination<GrowthChangeHistoryVO> selectPagination(Pagination<GrowthChangeHistoryVO> pagination) throws Exception {
        return this.executeSelectPagination(pagination, GrowthChangeHistoryVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(GrowthChangeHistoryDTO dto) throws Exception {
        return this.executeSaveOrUpdate(dto) > 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public GrowthChangeHistoryVO selectById(Long growthChangeHistoryId) throws Exception {
        return this.executeSelectById(growthChangeHistoryId, GrowthChangeHistoryVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(List<Long> growthChangeHistoryIds) {
        return this.baseMapper.deleteBatchIds(growthChangeHistoryIds) > 0;
    }

}
